package com.gxa.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.modules.sys.entity.OperationLog;
import com.gxa.modules.sys.entity.OperationLogAdd;
import com.gxa.modules.sys.entity.OperationLogUpdate;
import com.gxa.modules.sys.mapper.OperationLogMapper;
import com.gxa.modules.sys.service.OperationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
@Component
public class OperationLogServiceImpl implements OperationLogService {
    @Autowired
    private OperationLogMapper operationLogMapper;
    @Override
    public PageInfo<OperationLog> queryOperationLog(Map<String, Object> params) {
        String page1=(String) params.get("page");
        String limit1=(String)params.get("limit");
        Integer page=Integer.valueOf(page1);
        Integer limit=Integer.valueOf(limit1);

        //条件查询
        String employeeName = (String) params.get("employeeName");

        PageHelper.startPage(page,limit);

        List<OperationLog> operationLogs = this.operationLogMapper.queryOperationLog(employeeName);

        PageInfo<OperationLog> pageInfo = new PageInfo<>(operationLogs);
        return pageInfo;

    }

    @Override
    public void addOperationLog(OperationLogAdd operationLogAdd) {
        this.operationLogMapper.addOperationLog(operationLogAdd);
    }

    @Override
    public void updateOperationLog(OperationLogUpdate operationLogUpdate) {
        this.operationLogMapper.updateOperationLog(operationLogUpdate);
    }

    @Override
    public void deleteOperationLog(Integer id) {
        this.operationLogMapper.deleteOperationLog(id);
    }

    @Override
    public List<OperationLog> queryAll() {
        List<OperationLog> operationLogs = this.operationLogMapper.queryAll();
        return operationLogs;
    }

}
